﻿@model Nop.Web.Models.Boards.LastPostModel           
@using Nop.Web.Framework;
@using Nop.Services.Customers;
@using Nop.Services.Forums;
@using Nop.Services.Seo;
@if (@Model.forumPost != null)
{
    <div class="LastPost">
        @{        
            string dateStr = string.Empty;
            if (Model.RelativeDateTimeFormattingEnabled)
            {
                dateStr = @Model.forumPost.CreatedOnUtc.RelativeFormat(true, "f");
            }
            else
            {
                dateStr = (Nop.Core.Infrastructure.EngineContext.Current.Resolve<Nop.Services.Helpers.IDateTimeHelper>().ConvertToUserTime(@Model.forumPost.CreatedOnUtc, DateTimeKind.Utc).ToString("f"));
            }
            @dateStr <br />
        }
        @if (@Model.ShowTopic)
        {
            <text>@T("Forum.In"):</text>
             var topic = @Model.forumPost.ForumTopic;
             @Html.RouteLink(@topic.StripTopicSubject(), "TopicSlug", new { id = @topic.Id, slug = @topic.GetSeName() })
            <br />
        }
        @if (@Model.forumPost.Customer != null)
        {
            var authorText = @T("Forum.By");
            var authorName = Html.Encode(@Model.forumPost.Customer.FormatUserName(true));
            var allowViewingProfiles = Model.AllowViewingProfiles;
            var customerGuest = Model.forumPost.Customer.IsGuest();

            if (allowViewingProfiles && !customerGuest)
            {
                var output = String.Format("{0}: <a href=\"{2}\">{1}</a>", authorText, authorName, @Url.RouteUrl("CustomerProfile", new { id = Model.forumPost.Customer.Id }));
                @Html.Raw(output)
            }
            else
            {
                var output = String.Format("{0}: {1}", authorText, authorName);
                @output
            }
        }
    </div>
}
else
{
    <div class="nopost">
        @T("Forum.NoPosts")
    </div>
} 